function confirmLogin() {
    var cookie=getCookie('userId');

    if(cookie==""){
        window.location.href='../../index.html';
    }
    else
        window.location.href='../../login_index.html';
}

function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        }
    }
    return ""
}

function download_excel(type) {


    window.location.href = 'http://47.104.10.151:8080/doc/download?type='+type+'&user_id='+getCookie('userId')

}

function download_fail(type) {


    window.location.href = 'http://47.104.10.151:8080/doc/download_fail?user_id='+getCookie('userId')

}

function GetRequest() {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
            theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}

function init_modify() {
    var req = GetRequest();
    if (req.hasOwnProperty("uploadfail")){
        alert("文件上传成功,其中上传失败"+req.uploadfail+"条")
    }
    if (req.uploadfail>0){
        var basic = document.getElementById("basic-panel");
        var button = document.createElement("button");
        var em = document.createElement("em");
        var a = document.createElement("a");
        button.setAttribute("class","btn btn-default");
        button.setAttribute("type","button");
        button.setAttribute("style","margin-top: 16px;margin-left: 20px");
        em.setAttribute("class","glyphicon glyphicon-envelope");
        a.setAttribute("onclick","download_fail('stock')");
        a.innerHTML = "导出失败数据表格";
        button.appendChild(em);
        button.appendChild(a);
        basic.appendChild(button)
    }


}
